local lazy_keymaps = require('lin.plugs.conf.keymaps').lazy

return {
    { 'cbochs/grapple.nvim', keys = lazy_keymaps.grapple },
    {
        'nvim-telescope/telescope.nvim',
        branch = '0.1.x',
        keys = lazy_keymaps.telescope,
        opts = {
            pickers = {
                buffers = {
                    mappings = {
                        n = {
                            dd = 'delete_buffer'
                        }
                    }
                }
            }
        },
    },
    {
        'nvim-lualine/lualine.nvim',
        opts = {
            options = {
                disabled_filetypes = {
                    'NvimTree',
                },
                section_separators = { left = '', right = '' },
                component_separators = { left = '/', right = '/' }
            },
            sections = {
                lualine_x = { { 'encoding', icon = '#' }, { 'fileformat', icons_enabled = false }, 'filetype' },
                lualine_b = { 'branch', {
                    'diff',
                    source = function()
                        -- https://github.com/nvim-lualine/lualine.nvim/issues/799
                        local gitsigns = vim.b.gitsigns_status_dict
                        if gitsigns then
                            return {
                                added = gitsigns.added,
                                modified = gitsigns.changed,
                                removed = gitsigns.removed
                            }
                        end
                    end
                }, 'diagnostics' },
                lualine_c = {
                    {
                        'filename',
                        symbols = {
                            modified = '● ',
                            readonly = '(❗Read Only 👀)',
                        }
                    }
                }

            }
        }
    },
    {
        'nvim-tree/nvim-tree.lua',
        init = function()
            vim.api.nvim_create_autocmd({ 'VimEnter' }, {
                group = 'MyGroup',
                callback = function(data)
                    -- We lazily-load nvim-tree, this bootstraps it
                    if vim.fn.isdirectory(data.file) == 1 then
                        vim.cmd.cd(data.file)
                        require('nvim-tree.api').tree.open()
                    end
                end
            })
        end,
        opts = {
            on_attach = function(bufnr)
                local api = require('nvim-tree.api')
                api.config.mappings.default_on_attach(bufnr)
                vim.keymap.set('n', 'u', api.tree.change_root_to_parent, { buffer = bufnr })
                vim.keymap.set('n', '<c-h>', api.node.open.horizontal, { buffer = bufnr })
            end,
            sort_by = 'case_sensitive',
            view = {
                width = {
                    min = 20,
                    max = 50,
                },
            },
            git = {
                ignore = false
            },
            renderer = {
                icons = {
                    glyphs = {
                        git = {
                            unstaged = '', -- 󰏫  󰙏      󱃆 the original '✗' is kind of scary
                        }
                    }
                }
            },
        },
        keys = lazy_keymaps.nvim_tree
    },
}
